#include<stdio.h>
void sort(int arr1[], int arr2[], int n1,int  n2)
{ 
	int tem[20];
	int i = 0, j = 0, k = 0;
	while (1)
	{
		if (arr1[i] < arr2[j])
		{
		
			tem[k] = arr1[i];
			i++;
		}
		else
		{
		
			tem[k] = arr2[j];
			j++;

		}
		k++;
		if (i == n1)
			break;
	
	}
	for (k; k < n1 + n2; k++,j++)
		tem[k] = arr2[j];
	for (int t = 0; t < n1 + n2; t++)
		printf("%d ", tem[t]);
}

int main()
{
	int n1 = 0, n2 = 0;
	scanf_s("%d %d", &n1, &n2);
	int arr1[20];
	int arr2[20];
	for (int i = 0; i < n1; i++)
	{
		scanf_s("%d", &arr1[i]);
	}
	for (int i = 0; i < n2; i++)
	{
		scanf_s("%d", &arr2[i]);
	}
	if (arr1[n1 - 1] < arr2[n2 - 1])
	{
		sort(arr1, arr2, n1, n2);
	}
	else
		sort(arr2, arr1, n2, n1);

	return 0;
}